package cn.usian.user.controller;

import cn.usian.user.pojo.User;
import cn.usian.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @TODO:
 * @Author:baimu
 * @Date:2024 06 04 15 20
 **/
@RestController
@RequestMapping("/v1/api/user")
@Slf4j
@RefreshScope
public class UserController {


    private final UserService userService;


    public UserController(UserService userService) {
        this.userService = userService;
    }

    @Value(
            "${pattern.dateformat}"
    )
    private String dateformat;
    @RequestMapping("/getUserById")
    public User getUserById(Integer id){
        log.info("user-service1 getUserById:{}",id);
        return userService.getUserById(id);
    }

    @RequestMapping("/getDateFormat")
    public String now(){
        log.info("user-service1 getDateFormat:{}",dateformat);
        return LocalDateTime.now().format(DateTimeFormatter.ofPattern(dateformat));
    }
}
